﻿using System;
using System.Collections.Generic;
using System.Text;
using ORM.Annotations;

namespace Motorbike.Model
{
    /// <summary>
    /// 物流
    /// </summary>
    [EntityTable("b_waybill")]
    public class Waybill : Domain.Commons.DomainObject
    {

        /// <summary>
        /// 是否通知放货
        /// </summary>
        [EntityFeild("is_notice_release")]
        public bool IsNoticeRelease { get; set; }

        /// <summary>
        /// 是否送货上门
        /// </summary>
        [EntityFeild("is_doorstep_delivery")]
        public bool IsDoorstepDelivery { get; set; }

        /// <summary>
        /// 返利是否月结
        /// </summary>

        [EntityFeild("is_mothly_statement")]
        public bool IsMonthlyStatement { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [EntityFeild("comment")]
        public string Comment { get; set; }

        [EntityFeild("costomer_id")]
        public string CostomerId { get; set; }

        [EntityFeild("transport_company_id")]
        public string TransportCompanyId { get; set; }

        [EntityFeild("pricing_agreement_id")]
        public string PricingAgreementId { get; set; }

        [EntityFeild("create_date")]
        public DateTime CreateTime { get; set; }

        [EntityFeild("create_user_id")]
        public string CreateUser { get; set; }

        private IList<WaybillItem> _waybillItems;

        public IList<WaybillItem> WaybillItems
        {
            get { return _waybillItems; }
            set { _waybillItems = value; }
        }

        public void AddItem(WaybillItem item)
        {
            if (null == item)
            {
                return;
            }
            if (null == this._waybillItems)
            {
                this._waybillItems = new List<WaybillItem>();
            }
            if (!this._waybillItems.Contains(item))
            {
                this._waybillItems.Add(item);
            }
        }

        public static Waybill create(User creater)
        {
            Waybill waybill = new Waybill();
            waybill.CreateTime = DateTime.Now;
            waybill.CreateUser = creater.Id;
            return waybill;
        }
    }
}
